Operating System
Q201.
Semaphores are used to solve the problem ofI. Race ConditionII. Process SynchronizationIII. Mutual ExclusionIV. None of the aboveQ202.
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0. How many times will process P0 print '0'? How many times will process P0 print '0'?Q203.
Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?Q204.
The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores quipped with the standard P and V operations. semaphore S = 1, Q = 0; integer x; producer: consumer: while (true) do while (true) do P(S); P(Q); x = produce (); consume (x); V(Q); V(S); done done Which of the following is TRUE about the program above?Q205.
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows: void enter_CS(x) { while test-and-set(x) ; } void leave_CS(x) { x=0; } In the above solution, x is a memory location associated with the CS and is nitialized to 0. Now consider the following statements: I. The above solution to CS problem is deadlock-free II. The solution is starvation free. III. The processes enter CS in FIFO order. IV More than one process can enter CS at the same time. Which of the above statements is TRUE?Q206.
Consider the procedure below for the Producer-Consumer problem which uses semaphores: Which one of the following is TRUE?Q207.
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?Q209.
Synchronization in the classical readers and writers problem can be achieved through use of semaphores. In the following incomplete code for readers-writers problem, two binary semaphores mutex and wrt are used to obtain synchronization wait (wrt) writing is performed signal (wrt) wait (mutex) readcount = readcount + 1 if readcount = 1 then S1 S2 reading is performed S3 readcount = readcount - 1 if readcount = 0 then S4 signal (mutex) The values of S1, S2, S3, S4, (in that order) are